package admin

import (
	"github.com/astaxie/beego"
	"html/template"
	"strconv"
	"xianzhi/service"
	"xianzhi/utils"
)

type OrderController struct {
	BaseController
}

func (c *OrderController) ShowList() {
	curPage, _ := strconv.Atoi(c.GetString("p"))
	if curPage <= 0 {
		curPage = 1
	}
	perCount, _ := beego.AppConfig.Int("percount")
	symPageCount, _ := beego.AppConfig.Int("symmetricpagecount")
	p := map[string]interface{}{}
	realName := c.GetString("real_name")
	c.Data["realName"] = realName
	if len(realName) > 0 {
		p["realName"] = realName
	}
	nickName := c.GetString("nick_name")
	c.Data["nickName"] = nickName
	if len(nickName) > 0 {
		p["nickName"] = nickName
	}
	phone := c.GetString("phone")
	c.Data["phone"] = phone
	if len(phone) > 0 {
		p["phone"] = phone
	}
	p["relation"] = true
	p["convert"] = true
	p["curPage"] = curPage
	p["perCount"] = perCount
	totalCount, recordList := service.GetOrderList(p)
	paginator := utils.NewPaginator(int(totalCount), perCount, symPageCount, curPage)
	c.Data["paginator"] = paginator.GetPageHtml()
	c.Data["recordList"] = recordList
	c.Data["xsrfdata"] = template.HTML(c.XSRFFormHTML())
	c.TplName = "admin/order/list.html"
}